<?php

namespace app\admin\model;

use think\Model;

class AuthGroup extends Model
{

    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';

    public function getNameAttr($value, $data)
    {
        return __($value);
    }

    public static function getChildrenIds($ids)
    {
        static $output = [];
        if (!is_array($ids)) {
            $ids = explode(',', $ids);
        }
        $child_ids = self::whereIn('pid', $ids)->column('id');
        if (!empty($child_ids)){
            $output = array_merge($output, $child_ids);
            static::getChildrenIds($child_ids);
        }
        return $output;
    }

}
